package com.choosefine.springboot.devops.activityImg.service;

import com.choosefine.springboot.devops.activityImg.model.ActivityImg;
import com.choosefine.springboot.devops.base.config.MapUtil;
import com.choosefine.springboot.devops.base.service.BaseService;
import org.beetl.sql.core.SQLManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ActivityImgService extends BaseService {
	@Autowired
	private SQLManager activityImgMapper;

	public ActivityImg selectById(Integer id){
		ActivityImg result=activityImgMapper.selectUnique("ActivityImg.selectActivityImgById",id,ActivityImg.class);
		return result;
	}

	public List<ActivityImg> selectByActivityId(Integer id){
		Map<String,Object> param=new HashMap<String, Object>();
		param.put("activity",id);
		List<ActivityImg> list=activityImgMapper.select("activityImg.selectActivityImgByActivityId", ActivityImg.class, param);
		return list;
	}

	public void saveArray(ActivityImg activityImg, List<String> list){
		if(activityImg==null){
			activityImg=new ActivityImg();
		}
		for(String now:list){
			activityImg.setUrl(now);
			save(ActivityImg.class,MapUtil.transBean2Map(activityImg));
		}

	}
}
